package cn.itcast.order.config;


import cn.itcast.order.client.AccountClient;
import cn.itcast.order.client.StorageClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class FeignPreheater {
    @Autowired
    private AccountClient accountClient; // Feign 客户端接口
    @Autowired
    private StorageClient storageClient; // Feign 客户端接口

    @PostConstruct
    public void preheatFeign() {
        // 发送空请求触发初始化
        try {
            accountClient.healthCheck(); // 定义无业务逻辑的探针接口
            storageClient.healthCheck();
        } catch (Exception ignored) {
            // 忽略首次异常
        }
    }
}
